package ch.rheintalconnection.sysventory.businessServices;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import ch.rheintalconnection.sysventory.domain.Scan;
import ch.rheintalconnection.sysventory.domain.User;
import ch.rheintalconnection.sysventory.technicalServices.IDataWriter;

public class ScanningService {
	
	private NetworkScanner networkScanner;
	private IDataWriter dataWriter;
	private static Logger logger = LogManager.getLogger(ScanningService.class);

	public ScanningService(NetworkScanner networkScanner,
			IDataWriter dataWriter) {
		
		this.networkScanner = networkScanner;
		this.dataWriter = dataWriter;
	}
	
	public Scan scanAndStore(String ipmask, User user) {
		
		logger.info("Scan gestartet");
		Scan scan = networkScanner.scan(ipmask, user);
		logger.info("Scan beendet");
		
		dataWriter.store(scan);
		logger.info("Scan-Daten gespeichert");
		
		return scan;
	}

}
